package or.exa.cangguan.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import or.exa.cangguan.common.Result;
import or.exa.cangguan.entity.vo.UserVo;
import or.exa.cangguan.service.LoginService;
import org.apache.catalina.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
@Api(tags = "登录")
public class LoginController {

    @Autowired
    private LoginService loginService;


    @ApiOperation(value = "登录")
    @PostMapping("/login/login")
    public Result login(@RequestBody UserVo userVo) {
        String token = loginService.login(userVo.getUsername(), userVo.getPassword(), userVo.getVerificationCode(), userVo.getUuid());
        log.info(token);
        if (token == null) {
            return Result.err(501,"登录失败");
        }
        return Result.ok("登录成功",token);
    }





}
